//
//  DemoCollectionViewCell.swift
//  swift-practice
//
//  Created by 余振涛 on 2021/7/15.
//

import UIKit
import Masonry

class DemoCollectionViewCell: UICollectionViewCell {
    public var myLabel : UILabel!
    public var img : UIImageView!
    
    override init(frame: CGRect) {
        super.init(frame: frame)
        self.backgroundColor = .blue
        setupView()
    }
    
    required init?(coder: NSCoder) {
        super.init(coder: coder)
    }
    
    func setupView() {
        myLabel = UILabel.init()
        img = UIImageView.init()
        img.backgroundColor = .gray
        img.layer.cornerRadius = 5
        
        self.contentView.addSubview(img)
        self.contentView.addSubview(myLabel)
        
        myLabel.mas_makeConstraints { (make : MASConstraintMaker!)in
            make.right.left().equalTo()(self.contentView)
            make.bottom.equalTo()(self.contentView)?.offset()(-10)
        }
        
        img.mas_makeConstraints { (make : MASConstraintMaker!) in
            make.right.left().equalTo()(self.contentView)
            make.top.equalTo()(self.contentView)?.offset()(10)
            make.bottom.equalTo()(myLabel)?.offset()(-20)
        }
    }
    
}
